package yunhe.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONArray;

import yunhe.biz.StockMgrBiz;
import yunhe.biz.impl.StockMgrBizImpl;
import yunhe.entity.Inventory;
import yunhe.entity.Storage;
import yunhe.entity.Taking;

@WebServlet(name="GetProLossProductMsgServlet",urlPatterns="/GetProLossProductMsgServlet")
public class GetProLossProductMsgServlet extends HttpServlet
{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException
{
	doPost(req,resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException
	{
	
	StockMgrBiz stock=new StockMgrBizImpl();
	//寰楀埌浠庡墠涓�涓〉闈紶鏉ョ殑鏉″舰鐮佸��
	String proBarCode=req.getParameter("proBarcode");
	String stoName=req.getParameter("stoName");
	//鏍规嵁浠撳簱鍚嶈幏鍙栦粨搴搃d
	//寰楀埌鐩樼偣鍗曞彿
	String takId=req.getParameter("takId");
    System.out.println(takId);
    
	List<Storage> list=stock.queryStoByName(stoName);
    String stoId=list.get(0).getStoId();

    
    //鏍规嵁浠撳簱id鍜屽晢鍝佹潯褰㈢爜鏌ヨ鐩樼偣鍟嗗搧淇℃伅
	List<Taking> tak=stock.queryProLossByStoAndPro(stoId,takId,proBarCode);
	

	
	//璁剧疆浼犲叆涓嬩竴涓〉闈㈢殑鍙傛暟鍊�
	req.setAttribute("takId", takId);
	req.setAttribute("stoName", stoName);
	req.setAttribute("ProBarCode", tak.get(0).getProduct().getProBarCode());	
	req.setAttribute("ProName", tak.get(0).getProduct().getProName());
	req.setAttribute("ProQual", tak.get(0).getProduct().getProQual());
	req.setAttribute("ProUnit", tak.get(0).getProduct().getProUnit());
	req.setAttribute("PhaseNum", tak.get(0).getPhaseNum());
	req.setAttribute("ProPurchPrice", tak.get(0).getProduct().getProPurchPrice());


	req.getRequestDispatcher("breakeage.jsp").forward(req, resp);
	}
}

